#!/bin/sh

if test "$1" = "-h" || test "$1" = "--help" || test "$1" = ""; then
  echo
  echo "greps: searches psrchive source code for regular expression"
  echo
  echo "usage:"
  echo "  greps <regex>"
  echo
  exit
fi

if ack-grep --help > /dev/null 2>&1; then
  GREP_COMMAND=ack-grep
else
  if ack-grep --help > /dev/null 2>&1; then
    GREP_COMMAND=ack
  else
    GREP_COMMAND=grep
  fi
fi

$GREP_COMMAND $* `find Util Base More -name "*.[hfcC]"`

$GREP_COMMAND $* `find Util Base More -name Makefile.am`

$GREP_COMMAND $* `find Util Base More -name "*.tex"`

